
#ifndef _MEMBER_BNODE_H_
#define _MEMBER_BNODE_H_

#include <BNode>
#include <BShape>
#include <BShape>
#include <BState>
#include <BMaterial>
#include <BPhysics>
#include <BAnimation>

#define node_member(node)		((member_BNode*)((BNode*)node)->_ptr)

namespace BWE
{
	struct ShapeItem
	{
		inline ShapeItem()
		{
			visible = true;
			collible = true;
		}
		inline ShapeItem(BShape* shape)
		{
			visible = true;
			collible = true;
			this->shape = shape;
		}
		inline ShapeItem(const ShapeItem& other)
		{
			visible = other.visible;
			collible = other.collible;
			matrix = other.matrix;
			shape = other.shape;
		}

		inline bool operator == (const BShape* shape) const
		{
			return this->shape == shape;
		}
		inline bool operator != (const BShape* shape) const
		{
			return this->shape != shape;
		}

		bool			visible;
		bool			collible;
		BMatrix			matrix;
		BShapeHolder	shape;
	};

	class member_BNode : public BObject
	{
	public:
		member_BNode(BNode* node);
		~member_BNode();

		void update(const BEvent& event);
		void render(BRender& render);

		void procShapeSpaceChanged(BObject* object, const BValue& value);

	public:
		BNode*					boss;
		bool					visible;
		BMatrix					matrix;
		bool					dirtySpace;
		BSpace					space;
		BStateHolder			state;
		BPhysicsHolder			physics;
		BArray<ShapeItem>		shapeItems;
		BAnimationHolderArray	animations;
	};
}
#endif
